package cn.me.sso.service;
import cn.me.sso.constants.SsoServerConstant;
import cn.me.sso.utils.HttpUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
/**
 * 异步相关service
 * @author noodlesGood zchcpywin10
 */
@Service
@Slf4j
public class AsyncServiceImpl {
  /**
   * 异步调用客户端注销接口
   *
   * @param ssoSessionId String
   */
  @Async
  public void callClientLogout(String logoutUrl, String ssoSessionId) {
    try {
      if (!StringUtils.isEmpty(logoutUrl)) {
        String requestUrl = logoutUrl + "?" + SsoServerConstant.SSO_SESSION_ID + "=" + ssoSessionId;
        log.info("【异步调用客户端注销：】{}", requestUrl);
        HttpUtil.get(requestUrl, null);
      }
    }
    catch (Exception e) {
      log.error(e.getMessage(), e);
    }
  }
}
